import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import * as gc from 'src/app/global/const';
import { JsonResult } from '../global/model';

/**
 * 2021年3月7日 22:58:31
 * 本服务用于查询获取发货单以及对应的细码单数据
 * 作为推送的发货单微信模板消息的详情页连接显示的页面
 * 的后台服务
 */
@Injectable({
  providedIn: 'root'
})
export class BillDeliverService {

  // 表格列配置
  colConfig = [
    { fieldName:'pinming',caption:'品名',width:'60px' },
    { fieldName:'whitegg',caption:'规格',width:'70px' },
    { fieldName:'ps',caption:'匹数',width:'50px' },
    { fieldName:'qty',caption:'公斤',width:'50px' },
  ]

  private branch:string = 'billDeliver';
  private url = {
    'fhd':'https://www.jzy.world/whiteyc/fh/fhbill/',// 后面拼接发货单主表主键
    'xmd':'https://www.jzy.world/whiteyc/jrk/xmd/66154712', // 获取指定编号的细码单数据
  }

  constructor(
    private http:HttpClient
  ) { }

  // 获取发货单数据
  fhd(fhdId:number):Observable<JsonResult>{
    const url = this.url.fhd + fhdId;
    return this.http.get<JsonResult>(url);
  }

  xmd():Observable<JsonResult>{
    return this.http.get<JsonResult>(this.url.xmd);
  }

  getXmdUrl(code:string):Observable<JsonResult> {
    const url = "https://www.jzy.world/wxbe/white/bdbeu/" + code;
    return this.http.get<JsonResult>(url);
  }

}

// get请求：https://www.jzy.world/whiteyc/fh/fhbill/40
// 获取到的发货单数据的模型
export class BillDeliver {
  fhbarcode:string;
  pinming:string;
  delivery_address:string;
  ps:number;
  stevedore:string;
  bill_date:Date;
  ylgg:string;
  broker:string;
  whitegg:string;
  driver:string;
  phone:string;
  dyename:string;
  clientname:string;
  qty:number;
  id:number;
  number_plates:string;
}

export class XMD {
  b_barcode:string;
  b_id:number;
  b_aorb:string;
  b_itemid:number;
  b_rkdate:Date;
  b_gj:number;
  isfh:string;
  b_date:Date;
}